import 'package:flutter/material.dart';
import 'package:my_flutter_github/model/TrendingRepoModel.dart';
import 'package:my_flutter_github/model/UserEvent.dart';
import 'package:my_flutter_github/redux/ThemeRedux.dart';
import 'package:my_flutter_github/redux/UserRedux.dart';
import 'package:my_flutter_github/model/User.dart';
import 'package:my_flutter_github/redux/UserEventRedux.dart';
import 'package:my_flutter_github/redux/TrendRedux.dart';

class MyState {

  ///用户信息
  User userInfo;


  ///用户接受到的事件列表
  List<UserEvent> eventList = new List();

  ///用户接受到的事件列表
  List<TrendingRepoModel> trendList = new List();

  ThemeData themeData;


  MyState({this.userInfo, this.eventList, this.trendList, this.themeData});

}

///创建 Reducer
///源码中 Reducer 是一个方法 typedef State Reducer<State>(State state, dynamic action);
///我们自定义了 appReducer 用于创建 store
MyState appReducer(MyState state, action) {
    return MyState(
        ///通过 UserReducer 将 MyState 内的 userInfo 和 action 关联在一起
        userInfo: UserReducer(state.userInfo, action),
        eventList: UserEventReducer(state.eventList,action),
        trendList: TrendReducer(state.trendList, action),
        themeData: ThemeDataReducer(state.themeData, action),
    );
}